Skip to content

fix(preview): keep detail when zooming into tall images - #18102

Open
lavinhoque33 wants to merge 1 commit into
nextcloud:masterfrom
lavinhoque33:fix/viewer-full-resolution-zoom
Open

lavinhoque33 wants to merge 1 commit into
nextcloud:masterfrom
lavinhoque33:fix/viewer-full-resolution-zoom

Conversation

@lavinhoque33

@lavinhoque33 lavinhoque33 commented Nov 21, 2026 •

Copy link
Copy Markdown

Very tall images (comic strips, long screenshots, scanned receipts) cannot be read in the image viewer: they look blurry at every zoom level.

For a 540×21242 image on a 1080×2400 phone:

  • Not downloaded: the viewer asks the server for a preview of half the screen size (x=540&y=1170), which comes back about 30 pixels wide.
  • Downloaded: the file is decoded to fit the screen, which makes it 67×2655.
  • Both: PhotoView's maximum zoom is fixed at 3× the "whole image on screen" size, about 180 pixels wide on screen.

Changes

  • Not-downloaded images: the viewer still shows the cached screen-sized preview immediately, then loads a larger preview for display. It asks for a square of twice the screen's short side with mode=cover, which returns tall images at full width. This larger preview is not written to the thumbnail cache. If loading it fails, the cached preview stays on screen instead of an error.
  • Downloaded images: decoded at full resolution up to 16 MP, which keeps them below Android's 100 MB per-bitmap draw limit. On out-of-memory, the budget is quartered and the decode retried, as before.
  • Zoom levels are computed from the image's shape:
    • Double tap fills the view along the image's short side when the aspect ratio differs strongly from the view's, e.g. fit-to-width for a tall strip. Otherwise it stays at PhotoView's default 1.75×.
    • Maximum zoom goes past both that level and one image pixel per screen pixel.

Gallery thumbnails and the preview cache are unchanged.

Trade-off:

  • Opening a not-downloaded image downloads a larger preview than before (a few hundred KB to a few MB), and does so on every open.
  • The server caps preview size with preview_max_x/preview_max_y (default 4096). Strips taller than that need the admin to raise preview_max_y to get full width. Without that, they improve only as far as the cap allows.

Related: #15137 (full-resolution viewing of not-downloaded images, closed as not planned).

How to test

  1. On the server, upload a tall image such as 540×21242. If it's taller than 4096 px, set preview_max_y to 32768 in config.php.
  2. Open the image without downloading it, wait for the sharper version to replace the preview, then double-tap: the image should fill the screen width and the text should be readable. Pinch to zoom further.
  3. Make the image available offline and repeat.
  4. Open an ordinary photo and check that double tap and pinch zoom still feel normal.

🖼️ Screenshots

A 540×21242 test image, not downloaded, on a 1080×2340 phone. Before: maximum pinch zoom. After: one double tap.

🏚️ Before 🏡 After

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not needed
  • 🔙 Backport requests are created or not needed: /backport to stable-xx.x
  • 📅 Milestone is set
  • 🌸 PR title is meaningful (if it should be in the changelog: is it meaningful to users?)

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI (Claude Opus 5.5 via Claude Code)

Tested on a live Nextcloud server with an Android phone (1080×2340) and the 540×21242 image above.

lavinhoque33 added a commit to lavinhoque33/nextcloud-zoom that referenced this pull request Nov 21, 2026
Same behavior; cleanup for upstream review: shared decode helper, zoom levels in a testable DetailZoomScaleLevels, unit tests.
Tall images such as comic strips or long screenshots are unreadable in
the image viewer at every zoom level. Images that are not downloaded are
shown from a preview of half the screen size, downloaded ones are decoded
to fit the screen, and PhotoView stops zooming at 3x the fitted size, so
a 540x21242 image never gets wider than about 180 pixels on screen.

The viewer now loads a preview twice the screen's short side, or the
downloaded file at up to 16 MP, and derives its zoom levels from the
image's shape. The larger preview is not written to the thumbnail cache,
so the cache keeps its current size.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Iram Tazim Hoque <14330893+lavinhoque33@users.noreply.github.com>
@lavinhoque33
lavinhoque33 force-pushed the fix/viewer-full-resolution-zoom branch from 1d568f9 to 77b4fe1 Compare November 21, 2026 23:58
@lavinhoque33
lavinhoque33 marked this pull request as ready for review November 22, 2026 00:02

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant